package com.itheima.zuoye.d05;

import java.util.StringJoiner;

public class Test {
    public static void main(String[] args) {
        StringBuilderTime();
        StringJoinerTime();
    }



    public static void StringBuilderTime(){
        long start = System.currentTimeMillis();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < 100000000; i++) {
            sb.append(i);
        }
        long end = System.currentTimeMillis();
        System.out.println("StringBuilder执行时间：" + (end - start));
    }
    public static void StringJoinerTime(){
        long start = System.currentTimeMillis();
        StringJoiner sb = new StringJoiner(" ,");
        for (int i = 0; i < 100000000; i++) {
            sb.add("i");
        }
        long end = System.currentTimeMillis();
        System.out.println("StringBuilder执行时间：" +  (end - start));
    }

}
